﻿namespace _3_FactoryMethod;

public class Rectangle:Shape
{
    private double Length;
    private double Width;

    private Rectangle(double length, double width)
    {
        this.Length = length;
        this.Width = width;
    }

    public static Rectangle CreateInstance(double length, double width)
    {
        return new Rectangle(length, width);
    }

    public override double Area()
    {
        return Length * Width;
    }

    public override bool IsValid()
    {
        return Width > 0 && Length > 0;
    }

    public override string ToString()
    {
        return "Rectangle"+"\nLength "+Length+"\nWidth "+Width+"\nArea "+Area();
    }
}